package org.achartengine.internal.chart;

import android.graphics.Canvas;
import android.graphics.Paint;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.achartengine.internal.renderer.XYMultipleSeriesRenderer;

/* loaded from: classes2.dex */
public class j extends f {
    public static final String a = "Time";
    public static final long b = 86400000;
    private String h;

    @Override // org.achartengine.internal.chart.f, org.achartengine.internal.chart.k
    public String c() {
        return "Time";
    }

    j() {
    }

    public j(org.achartengine.internal.model.g gVar, XYMultipleSeriesRenderer xYMultipleSeriesRenderer) {
        super(gVar, xYMultipleSeriesRenderer);
    }

    public String d() {
        return this.h;
    }

    public void a(String str) {
        this.h = str;
    }

    @Override // org.achartengine.internal.chart.k
    protected void a(List<Double> list, Double[] dArr, Canvas canvas, Paint paint, int i, int i2, int i3, double d, double d2) {
        float f;
        int i4;
        boolean z;
        int size = list.size();
        boolean i5 = this.e.i();
        boolean j = this.e.j();
        DateFormat a2 = a(list.get(0).doubleValue(), list.get(size - 1).doubleValue());
        int i6 = 0;
        while (i6 < size) {
            long round = Math.round(list.get(i6).doubleValue());
            double d3 = i;
            double d4 = round;
            Double.isNaN(d4);
            Double.isNaN(d3);
            float f2 = (float) (d3 + ((d4 - d2) * d));
            if (i5) {
                paint.setColor(this.e.f());
                float f3 = i3;
                f = f2;
                i4 = size;
                z = i5;
                canvas.drawLine(f2, f3, f2, f3 + (this.e.g() / 3.0f), paint);
                a(canvas, a2.format(new Date(round)), f2, f3 + ((this.e.g() * 4.0f) / 3.0f), paint, this.e.ad());
            } else {
                f = f2;
                i4 = size;
                z = i5;
            }
            if (j) {
                paint.setColor(this.e.aa());
                canvas.drawLine(f, i3, f, i2, paint);
            }
            i6++;
            size = i4;
            i5 = z;
        }
    }

    private DateFormat a(double d, double d2) {
        if (this.h != null) {
            try {
                return new SimpleDateFormat(this.h);
            } catch (Exception unused) {
            }
        }
        DateFormat dateInstance = SimpleDateFormat.getDateInstance(2);
        double d3 = d2 - d;
        if (d3 <= 8.64E7d || d3 >= 4.32E8d) {
            return d3 < 8.64E7d ? SimpleDateFormat.getTimeInstance(2) : dateInstance;
        }
        return SimpleDateFormat.getDateTimeInstance(3, 3);
    }
}
